home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / cw15 / tpw15.z / CODE.TPW < prev    next >
Text File  |  1995-07-11  |  10KB  |  189 lines

  1. #!-------------------------------------------------------------------------
  2. #CODE(ControlValueValidation,'Control Value Validation'),HLP('~TPLCodeControlValueValidation')
  3. #RESTRICT
  4.   #CASE(%ControlType)
  5.   #OF('ENTRY')
  6.   #OROF('SPIN')
  7.   #OROF('COMBO')
  8.     #CASE(%ControlEvent)
  9.     #OF('Accepted')
  10.     #OROF('Selected')
  11.       #ACCEPT
  12.     #ELSE
  13.       #REJECT
  14.     #ENDCASE
  15.   #ELSE
  16.     #REJECT
  17.   #ENDCASE
  18. #ENDRESTRICT
  19. #DISPLAY('This Code Template is used to perform a control value')
  20. #DISPLAY('validation.  This Code Template only works for')
  21. #DISPLAY('the Selected or Accepted Events for an Entry Control.')
  22. #DISPLAY('')
  23. #PROMPT('Lookup Key',KEY),%LookupKey,REQ
  24. #PROMPT('Lookup Field',COMPONENT(%LookupKey)),%LookupField,REQ
  25. #PROMPT('Lookup Procedure',PROCEDURE),%LookupProcedure
  26. #DISPLAY('')
  27. #DISPLAY('The Lookup Key is the key used to perform the value validation.')
  28. #DISPLAY('If the Lookup Key is a multi-component key, you must insure that')
  29. #DISPLAY('other key elements are primed BEFORE this Code Template is used.')
  30. #DISPLAY('')
  31. #DISPLAY('The Lookup field must be a component of the Lookup Key.  Before execution')
  32. #DISPLAY('of the lookup code, this field will be assigned the value of the control being')
  33. #DISPLAY('validated, and the control will be assigned the value of the lookup field if')
  34. #DISPLAY('the Lookup procedure is successful.')
  35. #DISPLAY('')
  36. #DISPLAY('The Lookup Procedure is called to let the user to select a value.  Request')
  37. #DISPLAY('upon entrance to the Lookup will be set to SelectRecord, and successful')
  38. #DISPLAY('completion is signalled when Response = RequestCompleted.')
  39. #IF(%ControlEvent='Accepted')
  40.  IF %Control{Prop:Req} = False AND NOT %ControlUse #<! If not required and empty
  41.  ELSE
  42.    #INSERT(%CodeTPLValidationCode)
  43.  END
  44. #ELSIF(%ControlEvent='Selected')
  45.  #INSERT(%CodeTPLValidationCode)
  46. #ELSE
  47.   #ERROR('Value Validation Code Template must be used for Accepted or Selected Control Events!')
  48. #ENDIF
  49. #!-------------------------------------------------------------------------
  50. #GROUP(%CodeTPLValidationCode)
  51.  %LookupField = %ControlUse                        #<! Move value for lookup
  52. #FIND(%Field,%LookupField)                        #! FIX field for lookup
  53.  GET(%File,%LookupKey)                             #<! Get value from file
  54.  IF ERRORCODE()                                    #<! IF record not found
  55.    GlobalRequest = SelectRecord                    #<! Set Action for Lookup
  56.    %LookupProcedure                                #<! Call Lookup Procedure
  57.    LocalResponse = GlobalResponse                  #<! Save Returned Action
  58.    GlobalResponse = RequestCancelled               #<! Clear the Action Value
  59.    IF LocalResponse = RequestCompleted             #<! IF Lookup successful
  60.      %ControlUse = %LookupField                    #<! Move value to control field
  61. #IF(%ControlEvent='Accepted')                     #! IF a Post-Edit Validation
  62.    ELSE                                            #<! ELSE (IF Lookup NOT...)
  63.      SELECT(%Control)                              #<! Select the control
  64.      CYCLE                                         #<! Go back to ACCEPT
  65. #ENDIF                                            #! END (IF a Pre-Edit...)
  66.    END                                             #<! END (IF Lookup successful)
  67. #IF(%ControlEvent='Selected')                     #! IF a Pre-Edit Validation
  68.    SELECT(%Control)                                #<! Select the control
  69. #ENDIF                                            #! END (IF a Pre-Edit...)
  70.  END                                               #<! END (IF record not found)
  71. #!-------------------------------------------------------------------------
  72. #CODE(InitiateThread,'Initiate Thread Execution'),HLP('~TPLCodeInitiateThread')
  73. #DISPLAY('This Code Template is used to initiate a Thread.  The')
  74. #DISPLAY('code generated will follow the format:')
  75. #DISPLAY('')
  76. #DISPLAY('IF NOT START(Procedure)')
  77. #DISPLAY('  Error Handling')
  78. #DISPLAY('END')
  79. #DISPLAY('')
  80. #PROMPT('Procedure Name:',PROCEDURE),%ThreadProcedure
  81. #PROMPT('Thread Stack:',SPIN(@n7,5000,64000,500)),%ThreadStack,DEFAULT(25000)
  82. #PROMPT('Error Handling',@S255),%ThreadError
  83. #IF(%ThreadError)                                 #! IF Thread Error provided
  84.   #IF(%ThreadStack)
  85.  IF NOT START(%ThreadProcedure,%ThreadStack)       #<! IF Thread not initiated
  86.   #ELSE
  87.  IF NOT START(%ThreadProcedure)                    #<! IF Thread not initiated
  88.   #ENDIF
  89.    %ThreadError                                    #<! Perform the error code
  90.  END                                               #<! END (IF Thread not...)
  91. #ELSE                                             #! ELSE (IF NOT Thread Error...)
  92.   #IF(%ThreadStack)
  93.  START(%ThreadProcedure,%ThreadStack)              #<! Initiate the Thread
  94.   #ELSE
  95.  START(%ThreadProcedure)                          #<! Initiate the Thread
  96.   #ENDIF
  97. #ENDIF                                            #! END (IF Thread Error...)
  98. #!-------------------------------------------------------------------------
  99. #CODE(LookupNonRelatedRecord,'Lookup Non-Related Record'),HLP('~TPLCodeLookupNonRelatedRecord')
  100. #DISPLAY('This Code Template retrieves a non-related record from a file.')
  101. #DISPLAY('')
  102. #PROMPT('Lookup Key',KEY),%LookupKey,REQ
  103. #PROMPT('Lookup Field',COMPONENT(%LookupKey)),%LookupField,REQ
  104. #PROMPT('Related Field',FIELD),%RelatedField,REQ
  105. #DISPLAY('')
  106. #DISPLAY('The Lookup Key is the key used to perform the lookup.  If the Lookup')
  107. #DISPLAY('Key is a multi-component key, you must insure that the other key')
  108. #DISPLAY('elements are primed BEFORE this Code Template is executed.')
  109. #DISPLAY('')
  110. #DISPLAY('The Lookup field must be a component of the Lookup Key.  Before execution')
  111. #DISPLAY('of the lookup code, this field will be assigned the value of the related field.')
  112. #DISPLAY('')
  113. #DISPLAY('The Related field is a component of the primary file, which relates to the')
  114. #DISPLAY('lookup field.')
  115. #DISPLAY('')
  116.  %LookupField = %RelatedField                      #<! Move value for lookup
  117. #FIND(%Field,%LookupField)                        #! FIX field for lookup
  118.  GET(%File,%LookupKey)                             #<! Get value from file
  119.  IF ERRORCODE()                                    #<! IF record not found
  120.    CLEAR(%FilePrefix:Record)                       #<! Clear the record buffer
  121.  END                                               #<! END (IF record not found)
  122. #!-------------------------------------------------------------------------
  123. #CODE(CallProcedureAsLookup,'Call Procedure as Lookup'),HLP('~TPLCodeCallProcedureAsLookup')
  124. #DISPLAY('This Code Template calls a procedure as a lookup.')
  125. #DISPLAY('')
  126. #PROMPT('Lookup Procedure',PROCEDURE),%LookupProcedure,REQ
  127. #PROMPT('Code Before',@S255),%CodeBeforeLookup
  128. #PROMPT('Code After, Completed',@S255),%CodeOnComplete
  129. #PROMPT('Code After, Cancelled',@S255),%CodeOnCancel
  130. #DISPLAY('')
  131. #DISPLAY('This Code Template is used to call any procedure as a "Lookup."  Before')
  132. #DISPLAY('the call is made the global variable "Request" is set to a value of')
  133. #DISPLAY('SelectRecord.  Upon return, the value of Action is copied to a local')
  134. #DISPLAY('holding variable (Action:Returned), then cleared.')
  135. #DISPLAY('')
  136. #DISPLAY('The value of Action:Returned upon return from the called procedure')
  137. #DISPLAY('determines if the lookup is considered "Completed".  An Action:Returned')
  138. #DISPLAY('value of 9 (Action:Completed) indicates that the lookup was successful.')
  139. #DISPLAY('Any other value indicates that the lookup was cancelled.')
  140. #DISPLAY('')
  141. #DISPLAY('The Action:Returned variable should be used in any EMBED code after')
  142. #DISPLAY('this Code Template to check for Lookup completion.')
  143. #DISPLAY('')
  144. #DISPLAY('A Browse Template procedure automatically senses if an Action of')
  145. #DISPLAY('Action:Lookup and functions accordingly.')
  146.   OMIT('->')
  147. !----------------------------------------
  148. | CallProcedureAsLookup
  149. | Lookup Procedure    %LookupProcedure
  150. | Before Lookup:      %CodeBeforeLookup
  151. | After Complete:     %CodeOnComplete
  152. | After Cancel:       %CodeOnCancel
  153. !--------------------------------------->
  154. #IF(%CodeBeforeLookup)
  155.  %CodeBeforeLookup                                 #<! Source before Lookup
  156. #ENDIF
  157.  GlobalRequest = SelectRecord                      #<! Set Action for Lookup
  158.  %LookupProcedure                                  #<! Call the Lookup Procedure
  159.  LocalResponse = GlobalResponse                    #<! Save Action for evaluation
  160.  GlobalResponse = RequestCancelled                 #<! Clear Action
  161. #IF(%CodeOnComplete AND %CodeOnCancel)
  162.  IF LocalResponse = RequestCompleted               #<! IF Lookup completed
  163.    %CodeOnComplete                                 #<! Source on Completion
  164.  ELSE                                              #<! ELSE (IF Lookup NOT...)
  165.    %CodeOnCancel                                   #<! Source on Cancellation
  166.  END                                               #<! END (IF Lookup completed)
  167. #ELSIF(%CodeOnComplete)
  168.  IF LocalResponse = RequestCompleted               #<! IF Lookup completed
  169.    %CodeOnComplete                                 #<! Source on Completion
  170.  END                                               #<! END (IF Lookup completed)
  171. #ELSIF(%CodeOnCancel)
  172.  IF LocalResponse = RequestCancelled               #<! IF Lookup completed
  173.    %CodeOnCancel                                   #<! Source on Cancellation
  174.  END                                               #<! END (IF Lookup NOT completed)
  175. #ENDIF
  176. #!-------------------------------------------------------------------------
  177. #CODE(CloseCurrentWindow,'Close Current Window and Procedure'),HLP('~TPLCodeCloseCurrentWindow')
  178. #DISPLAY('There are no prompts to fill out for this Code Template.')
  179. #DISPLAY('')
  180. #DISPLAY('This Code Template initiates the triggers the shut-down')
  181. #DISPLAY('of the active procedure.  It does this by triggering')
  182. #DISPLAY('Event:CloseWindow, using the command:')
  183. #DISPLAY('')
  184. #DISPLAY('  POST(Event:CloseWindow)')
  185. #DISPLAY('')
  186. #DISPLAY('Use the Source Point: "Window Event: Close Window" to ')
  187. #DISPLAY('execute any code upon window close down.')
  188.  POST(Event:CloseWindow)
  189.